<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class ShoufeiController extends AdminbaseController{

    protected $shoufei_model;
    protected $gongshi_model;

            
    function _initialize() {
        parent::_initialize();
        $this->shoufei_model = M("sftemplate");
       $this->gongshi_model = M("gongshiguanli");
    }

   public function gongshiadd(){
        $this->display();
    }

    public function gongshiguanli(){
        $info=$this->gongshi_model->select();
        $this->assign('info', $info);
            $this->display();
    }

    public function gongshiadd_post() {
    	if (IS_POST) {
    		if ($this->gongshi_model->create()) {
    			if ($this->gongshi_model->add()!==false) {
                                $this->gongshi_model->add();
    				$this->success("添加成功！");
    			} else {
    				$this->error("添加失败！");
    			}
    		} else {
    			$this->error($this->gongshi_model->getError());
    		}
    	}
    }
    
    function gongshidelete(){
        $id = intval(I("get.id")); 
          $count = $this->gongshi_model->where(array("parentid" => $id))->count();
    
        if ($this->gongshi_model->delete($id)!==false) {
            $this->success("删除成功！");
        } else {
            $this->error("删除失败！");
        }        
    }
    
    function gongshiupdata(){
        $id = intval(I("get.id"));
        $res=$this->gongshi_model->where('id=%d',array($id))->select();
        $this->assign('res', $res);
        $this->display(); 
    }
    function gongshi_save(){
       	if (IS_POST) {
    		if ($this->gongshi_model->create()) {
    			if ($this->gongshi_model->save()!==false) {
                            $ar=array(
    				'name'=>$_POST['title'],
                                'content'=>$_POST['content'],
                                'istop'=>$_POST['istop']
                                );
                               $this->gongshi_model->where('id=%d',array($_POST['id']))->save();
    				 $this->success("更新成功！");
    			} else {
    				$this->error("更新失败！");
    			}
    		} else {
    			$this->error($this->gongshi_model->getError());
    		}
    	}
    }
function shoufeimoban(){
    
    	
            $info=$this->shoufei_model->select();
            
      
            
            $this->assign('info', $info);
		
    
    $this->display();
}

function mb_add(){
    
    $res=$this->gongshi_model->select();
    
    $this->assign('res',$res);
    
    $this->display();
}
function mb_delete(){
    
     $id = intval(I("get.id")); 
          $count = $this->shoufei_model->where(array("parentid" => $id))->count();
    
        if ($this->shoufei_model->delete($id)!==false) {
            $this->success("删除成功！");
        } else {
            $this->error("删除失败！");
        }
    
}
function mb_addPost(){
    if (IS_POST) {
    		if ($this->shoufei_model->create()) {
    			if ($this->shoufei_model->add()!==false) {
                         
                         
                               $this->shoufei_model->add();
    				 $this->success("添加成功！");
    			} else {
    				$this->error("添加失败！");
    			}
    		} else {
    			$this->error($this->shoufei_model->getError());
    		}
               
    	}    
}
function deal(){
    
    
    $this->display();
            
}
function cashier(){
    
    $this->display();
    
}
}